package com.nage.components.touch;

import android.util.Log;

import com.nage.components.display.Shape;
import com.nage.engine.GameGraph;
import com.nage.engine.GameObject;
import com.nage.graphics.RenderSystem;

public class AddSquareButton extends Touchable {
	// Defines an area of screen that when pressed will create a new shape on the screen
	
	public AddSquareButton(GameObject p) {
		super(p);
		type = ADD_SQUARE_BUTTON;
	}

	private static int count = 0;

	@Override
	public void onTouch() {
		GameGraph graph = parent.parent; // the game graph that this is all living in.
		GameObject obj = new GameObject(graph); // new object we will add to the graph.
		obj.setX((float)(Math.random()*RenderSystem.view[2])); // set x position to random between 0 and width
		obj.setY((float)(Math.random()*RenderSystem.view[3])); // set y position to random between 0 and height
		obj.m_Name = "RandomSquare"+count ++;
		Shape s = new Shape(obj);
		s.width = 20;
		s.height = 20;
		s.setRGB("ffff44");
		obj.addComponent(s);
		graph.addWhenPossible(obj);
		Log.v("AddSquare", "Should be added now... by GameObject: "+parent.m_Name);			
	}

}
